package com.ruoyi.pingjiao.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pingjiao.domain.PaperItem;
import com.ruoyi.pingjiao.service.IPaperItemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 评教问卷项管理Controller
 * 
 * @author 胡浩鹏
 * @date 2022-10-23
 */
@RestController
@RequestMapping("/pingjiao/item")
public class PaperItemController extends BaseController
{
    @Autowired
    private IPaperItemService paperItemService;

    /**
     * 查询评教问卷项管理列表
     */
    @PreAuthorize("@ss.hasPermi('pingjiao:item:list')")
    @GetMapping("/list")
    public TableDataInfo list(PaperItem paperItem)
    {
        startPage();
        List<PaperItem> list = paperItemService.selectPaperItemList(paperItem);
        return getDataTable(list);
    }

    /**
     * 导出评教问卷项管理列表
     */
    @PreAuthorize("@ss.hasPermi('pingjiao:item:export')")
    @Log(title = "评教问卷项管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PaperItem paperItem)
    {
        List<PaperItem> list = paperItemService.selectPaperItemList(paperItem);
        ExcelUtil<PaperItem> util = new ExcelUtil<PaperItem>(PaperItem.class);
        util.exportExcel(response, list, "评教问卷项管理数据");
    }

    /**
     * 获取评教问卷项管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('pingjiao:item:query')")
    @GetMapping(value = "/{paperItemId}")
    public AjaxResult getInfo(@PathVariable("paperItemId") Long paperItemId)
    {
        return AjaxResult.success(paperItemService.selectPaperItemByPaperItemId(paperItemId));
    }

    /**
     * 新增评教问卷项管理
     */
    @PreAuthorize("@ss.hasPermi('pingjiao:item:add')")
    @Log(title = "评教问卷项管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PaperItem paperItem)
    {
        return AjaxResult.success(paperItemService.insertPaperItem(paperItem));
    }

    /**
     * 修改评教问卷项管理
     */
    @PreAuthorize("@ss.hasPermi('pingjiao:item:edit')")
    @Log(title = "评教问卷项管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PaperItem paperItem)
    {
        return toAjax(paperItemService.updatePaperItem(paperItem));
    }

    /**
     * 删除评教问卷项管理
     */
    @PreAuthorize("@ss.hasPermi('pingjiao:item:remove')")
    @Log(title = "评教问卷项管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{paperItemIds}")
    public AjaxResult remove(@PathVariable Long[] paperItemIds)
    {
        return toAjax(paperItemService.deletePaperItemByPaperItemIds(paperItemIds));
    }
}
